package com.rongshu.view.userInfo.presenter;

import android.content.Context;

import com.rongshu.api.RetorfitService;
import com.rongshu.view.base.mvp.BasePresenter;
import com.rongshu.view.base.mvp.INetBean;
import com.rongshu.view.userInfo.entity.ThirdPartyInfo;
import com.rongshu.view.userInfo.iview.ThirdBindView;

import rx.Subscriber;

public class ThirdBindPresenter extends BasePresenter<ThirdBindView> {

    public ThirdBindPresenter(Context context) {
        super(context);
    }

    /**
     * 第三方账户绑定
     */
    public void getBindingQQWechatWeiBo(int user_id, int type, String open, String nickname, String sign) {
        RetorfitService.getBindingQQWechatWeiBo(user_id, type, open, nickname, sign)
                .subscribe(new Subscriber<INetBean>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(INetBean bean) {
                        if (getView() != null) {
                            getView().onThirdBind(bean);
                        }
                    }
                });

    }

    /**
     * 获取第三方账号绑定信息和实名认证信息
     */
    public void getThirdParty(int user_id, String sign) {
        RetorfitService.getThirdParty(user_id, sign)
                .subscribe(new Subscriber<ThirdPartyInfo>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(ThirdPartyInfo info) {
                        if (getView() != null) {
                            getView().onThirdPartyInfo(info);
                        }
                    }
                });
    }

    /**
     * 第三方账户解绑
     */
    public void getUnlinkQQWechatWeiBo(int user_id, int type, String sign) {
        RetorfitService.getUnlinkQQWechatWeiBo(user_id, type, sign)
                .subscribe(new Subscriber<INetBean>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(INetBean bean) {
                        if (getView() != null) {
                            getView().onThirdUnBind(bean);
                        }
                    }
                });

    }
}
